/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 26727
 * Date: 2025-08-14
 * Time: 23:30
 */
public class Test80 {
    public static boolean canJump(int[] num) {
        int n = num.length;
        int left = 0, right = 0, maxIndex = 0,ret = 0;
        while(left <= right) {
            if(maxIndex >= n-1) {
                return true;
            }
            for(int i = left; i <= right; i++) {
                maxIndex = Math.max(num[i]+i,maxIndex);
            }
            ret++;
            left = right+1;
            right = maxIndex;
        }
        return false;
    }

    public static void main(String[] args) {
        int[] num = {2,3,1,1,4};
        boolean ret = canJump(num);
        System.out.println(ret);
    }
}
